# Maintainer: Julien (jvoisin) Voisin <julien.voisin+snuffleupagus@dustri.org>

pkgname=php7-snuffleupagus
_extname=snuffleupagus
pkgver=0.7.1
pkgrel=0
pkgdesc="Security module for PHP 7"
url="https://snuffleupagus.readthedocs.io"
arch="all"
license="LGPL-3.0-only"
depends="php7-common"
builddir="$srcdir/$_extname-$pkgver/src"
makedepends="php7-dev php7-cgi"
source="php-$_extname-$pkgver.tar.gz::https://github.com/jvoisin/snuffleupagus/archive/v$pkgver.tar.gz"

build() {
	phpize7
	./configure \
		--prefix=/usr \
		--enable-snuffleupagus \
		--with-php-config=php-config7
	make
}

check() {
	TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make test TESTS="tests/cookies_encryption tests/deny_writable"
	TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make test TESTS="tests/global_strict"
	TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make test TESTS="tests/harden_rand tests/sloppy_comparison tests/unserialize"

	# TODO re-enable these tests
	#TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make test TESTS="tests/disable_function"
	#TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make test TESTS="tests/xxe"
	#TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make test TESTS="tests/eval_blacklist"
	#TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make test TESTS="tests/dump_request"
}

package() {
	make INSTALL_ROOT="$pkgdir" install
	local _confdir="$pkgdir"/etc/php7/conf.d
	install -d $_confdir
	install -m644 ../config/$_extname.ini $_confdir/$pkgname.ini
	install -m644 ../config/default.rules $_confdir/$_extname.rules
}

sha512sums="21510e214f94dd50a4aa05226188c9433a6a261c0bd3d58973ed4536754b3e12356e3f625480c370b66c570482694c25d336a771fbbbeb27e1d524b1f82c7869  php-snuffleupagus-0.7.1.tar.gz"
